package org.springblade.modules.admin.task;

import cn.hutool.core.date.DateUtil;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springblade.modules.admin.service.IMaintainPlanScoreRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Description 保养工单评分推送任务
 * @Author ysq
 * @Date 2022/9/27
 **/
@Component
public class OrderScoreJob {

	@Autowired
	private IMaintainPlanScoreRecordService maintainPlanScoreRecordService;

	/**
	 * 每天12点
	 * 工单评分-消息推送
	 */
	//@Scheduled(cron = "0 0 12 * * ? ")
	@XxlJob(value = "sendWechatTemplate")
	public void sendWechatTemplate() {
		XxlJobHelper.handleSuccess("工单评分-(sendWechatTemplate)-[执行]开始");
		try {
			maintainPlanScoreRecordService.sendWechatTemplate(DateUtil.yesterday());
			XxlJobHelper.handleSuccess("工单评分-(sendWechatTemplate)-[执行]成功");
		} catch (Exception e) {
			XxlJobHelper.handleSuccess("工单评分-(sendWechatTemplate)-[执行]失败" + e);
		}

	}

	/**
	 * 每天12点10分
	 * 新工单评分-消息推送
	 */
	@XxlJob(value = "sendPlanScoreMessage")
	public void sendPlanScoreMessage() {
		XxlJobHelper.handleSuccess("工单评分-(sendWechatTemplate)-[执行]开始");
		try {
			maintainPlanScoreRecordService.sendPlanScoreMessage(DateUtil.yesterday());
			XxlJobHelper.handleSuccess("工单评分-(sendWechatTemplate)-[执行]成功");
		} catch (Exception e) {
			XxlJobHelper.handleSuccess("工单评分-(sendWechatTemplate)-[执行]失败" + e);
		}

	}

}
